package com.lxq.www.controller;

import com.lxq.www.pojo.GlobalNotice;
import com.lxq.www.service.GlobalNoticeService;
import com.lxq.www.service.MQFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class NoticeController {

    @Autowired
    GlobalNoticeService globalNoticeService;
    @Autowired
    MQFactory mqFactory;
    @Autowired
    JmsMessagingTemplate messagingTemplate;

    @GetMapping("notice/testing")
    public String testing(){
        return "<h1>成功是失败它儿砸呀</h1>";
    }

    @GetMapping("notice/index/{noticeid}")
    public GlobalNotice getNoticeOf1(@PathVariable int noticeid){
        return globalNoticeService.getNotice(noticeid);
    }

    @GetMapping("/mqtest/{msg}")
    public String mqTest(@PathVariable String msg){
        messagingTemplate.convertAndSend(mqFactory.getLiveQueue(),msg);
        return "已发送";
    }
}
